import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SLadderResult } from "../../../../Message/Public/SLadderResult";
import { ItemData } from "../../resource/info/ItemData";
import { LadderBattlefieldGroupResult } from "./LadderBattlefieldGroupResult";
import { ObjCreate } from "../common/ObjCreate";
import { LadderBattlefieldGroupDetail } from "./LadderBattlefieldGroupDetail";
import { ImagesConst } from "../../resource/ImagesConst";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { BaseItem } from "../common/BaseItem";
import { GSprite } from "../../../../com/mui/controls/GSprite";
//class LadderBattlefieldResultWindow
    
    export  class LadderBattlefieldResultWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(377, 260);
            titleHeight = 26;
            title = Language.getString(42242);
            return;
        }

        /* internal  */onBtnOKClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.hide();
            Dispatcher.dispatchEvent(new DataEvent(EventName.LadderBattlefieldLeave, {"needShowAlert": false}));
            return;
        }

        /* internal  */showDetails(arg1: DataEvent): void
        {
            this._groupDetail.visible = true;
            return;
        }

        public updateResult(arg1: SLadderResult): void
        {
            this._groupDetail.visible = false;
            if (arg1.groupOne.length > 1) 
            {
                this._groupDetail.updateData(arg1.groupOne);
            }
            if (arg1.groupTwo.length > 1) 
            {
                this._groupDetail.updateData(arg1.groupTwo);
            }
            this._groupResultOne.updateResult(arg1.groupOne, arg1.groupOneResult, false);
            this._groupResultTwo.updateResult(arg1.groupTwo, arg1.groupTwoResult, false);
            if (arg1.itemReward != 0) 
            {
                this._spItemReward.visible = true;
                this._baseItem.itemData = new ItemData(arg1.itemReward);
                this._baseItem.width = 32;
                this._baseItem.height = 32;
                this._baseItem.drawNow();
            }
            else 
            {
                this._spItemReward.visible = false;
            }
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._groupResultOne = new LadderBattlefieldGroupResult();
            ObjCreate.setObjAttri(this._groupResultOne, 17, 40, -1, -1, this);
            this._groupResultTwo = new LadderBattlefieldGroupResult();
            ObjCreate.setObjAttri(this._groupResultTwo, 190, 40, -1, -1, this);
            this._groupDetail = new LadderBattlefieldGroupDetail();
            ObjCreate.setObjAttri(this._groupDetail, 377, 0, -1, -1, this);
            ObjCreate.createGBitmap(ImagesConst.ArenaVS, 167, 98, this);
            ObjCreate.createGButton(Language.getString(42243), 158, 220, 55, 22, this, "Button", this.onBtnOKClick);
            var loc1=new GTextFormat(FontUtil.songtiName, 14, 15788607);
            this._spItemReward = ObjCreate.createGSprite();
            ObjCreate.setObjAttri(this._spItemReward, 188, 210, -1, -1, this);
            ObjCreate.createGTextFiledBitmap(Language.getString(42245), 0, 0, 65, 22, this._spItemReward, loc1);
            ObjCreate.createGBitmap(ImagesConst.PackItemBg, 65, 0, this._spItemReward);
            this._baseItem = new BaseItem();
            ObjCreate.setObjAttri(this._baseItem, 68, 3, -1, -1, this._spItemReward);
            return;
        }

        /* internal */ /* var */_groupResultOne: LadderBattlefieldGroupResult;

        /* internal */ /* var */_groupResultTwo: LadderBattlefieldGroupResult;

        /* internal */ /* var */_groupDetail: LadderBattlefieldGroupDetail;

        /* internal */ /* var */_spItemReward: GSprite;

        /* internal */ /* var */_baseItem: BaseItem;
    }
